package com.mxpio.erp.common.equipment.entity;

import com.mxpio.erp.common.jpa.policy.ResCodeGeneratorPolicy;
import com.mxpioframework.filestorage.entity.MxpioFileInfo;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.Date;


@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_KNOWLEDGE_BASE")
@Schema(description="知识库")
public class KnowledgeBase extends BaseEntity {
    private static final long serialVersionUID=-1L;

    @Id
    @Generator
    @Column(name = "ID_")
    @Schema(description = "主键")
    private String id;

    @Column(name = "KNOWLEDGE_CODE_")
    @Schema(description = "知识编码")
    @Generator(policy = ResCodeGeneratorPolicy.class)
    private String knowledgeCode;

    @Column(name = "KNOWLEDGE_TITLE_")
    @Schema(description = "知识标题")
    private String knowledgeTitle;

    @Column(name = "KNOWLEDGE_TYPE_ID_")
    @Schema(description = "知识类型ID")
    @Dict(dicCode = "typeId", dicEntity = KnowledgeType.class, dicText = "typeName")
    private String knowledgeTypeId;

    @Column(name = "KNOWLEDGE_LABEL_")
    @Schema(description = "标签")
    @Dict(dicCode = "tagCode", dicEntity = EquipmentKnowledgeTag.class, dicText = "tagName")
    private String knowledgeLabel;

    @Column(name = "ATTACH_")
    @Dict(dicCode = "fileNo", dicEntity = MxpioFileInfo.class, dicText = "fileName")
    @Schema(description = "附件")
    private String attach;

    @Column(name = "KNOWLEDGE_OBJ_")
    @Schema(description = "知识对象")
    @Dict(dicCode = "knowledgeObj")
    private String knowledgeObj;

    @Column(name = "KNOWLEDGE_OBJ_CODE_")
    @Schema(description = "知识对象编码")
    private String knowledgeObjCode;

    @Column(name = "KNOWLEDGE_OBJ_NAME_")
    @Schema(description = "知识对象名称")
    private String knowledgeObjName;

    @Column(name = "VERSION_")
    @Schema(description = "版本")
    private Integer version=1;

    @Column(name = "SOURCE_")
    @Schema(description = "数据来源")
    private String source="手动增加";

    @Column(name = "MEMO_")
    @Schema(description = "备注")
    private String memo;

    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(name = "KNOWLEDGE_",columnDefinition="TEXT")
    @Schema(description = "知识描述")
    private String knowledge;

    /**
     * 0-失效  1-生效  2-升版待审批  9-升版驳回
     */
    @Column(name = "STATUS_")
    @Schema(description = "状态")
    private String status="1";

    @Column(name = "PREV_ID_",updatable = false)
    @Schema(description = "前一版本ID")
    private String prevId;

    @Column(name = "AUDIT_TIME_")
    @Schema(description = "审核时间")
    private Date auditTime;

    @Column(name = "AUDIT_USER_")
    @Schema(description = "审核人")
    private String auditUser;

    @Column(name = "AUDIT_VIEW_")
    @Schema(description = "审核意见")
    private String auditView;

    @Column(name = "EFFECTIVE_TIME_")
    @Schema(description = "生效时间")
    private Date effectiveTime;

    @Column(name = "EXPIRING_TIME_")
    @Schema(description = "失效时间")
    private Date expiringTime;

    @Column(name = "FALIMY_",updatable = false)
    @Schema(description = "知识家族标志")
    private String family;

}
